class ListNode {
  constructor(val, next = null) {
    this.val = val;   // 节点值
    this.next = next; // 指向下一个节点的指针
  }
}
const head = new ListNode(1, new ListNode(2, new ListNode(3)));

console.log(head);
let current = head;
while (current) {
  console.log(current.val); // 依次输出 1, 2, 3
  current = current.next;
}